﻿<%@ Page Title="" Language="C#" MasterPageFile="NewAccountMasterPage.Master" AutoEventWireup="true"
    CodeBehind="InsertBook.aspx.cs" Inherits="AteneoLibri.Account.InsertBook" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        <asp:Label ID="PageTitle" runat="server" Text="Inserisci libro"></asp:Label>
    </h2>
    <asp:Panel ID="pnlInsertBook" runat="server">
        <div style="width: 100%; overflow: auto;">
            <div id="leftRegistration" class="Registration">
                <asp:Label ID="lblTitle" runat="server" Text="Titolo"></asp:Label><br />
                <asp:TextBox ID="txtTitle" CssClass="StandardTextBox" runat="server"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="rfvTitle" runat="server" ErrorMessage="* Campo obbligatorio"
                    ValidationGroup="vgInsertBook" CssClass="failureNotification" Display="Dynamic"
                    ControlToValidate="txtTitle"></asp:RequiredFieldValidator>
                <br />
                <asp:Label ID="lblAuthors" runat="server" Text="Autore/i"></asp:Label><br />
                <asp:TextBox ID="txtAuthors" CssClass="StandardTextBox" runat="server"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="rfvAuthors" runat="server" ErrorMessage="* Campo obbligatorio"
                    ValidationGroup="vgInsertBook" CssClass="failureNotification" Display="Dynamic"
                    ControlToValidate="txtAuthors"></asp:RequiredFieldValidator>                
                <br />
                <asp:Label ID="lblPublishingHouse" runat="server" Text="Casa editrice"></asp:Label><br />
                <asp:TextBox ID="txtPublishingHouse" CssClass="StandardTextBox" runat="server"></asp:TextBox>
                <br />
                <br />
                <asp:Label ID="lblEdition" runat="server" Text="Edizione"></asp:Label><br />
                <asp:TextBox ID="txtEdition" CssClass="StandardTextBox" runat="server"></asp:TextBox>
                <br />
                <br />
                <asp:Label ID="lblNote" runat="server" Text="Note"></asp:Label><br />
                <asp:TextBox ID="txtNote" CssClass="StandardTextBox" runat="server" TextMode="MultiLine" Rows="4"></asp:TextBox><br />
                <br />
                <asp:HiddenField ID="hfCoverImagePath" runat="server" />
            </div>
            <div id="rightRegistration" class="Registration">
                <asp:Label ID="lblSellingPrice" runat="server" Text="Prezzo di vendita"></asp:Label><br />
                <asp:TextBox ID="txtSellingPrice" CssClass="StandardTextBox StandardTextBoxSmaller" runat="server"></asp:TextBox>&nbsp;<asp:Label ID="lblCurrency"
                    runat="server"></asp:Label><br />
                <asp:CompareValidator ID="cvSellingPrice" runat="server" ErrorMessage="Dato non valido. Inserire il prezzo nel seguente formato 12,50"
                    CssClass="failureNotification" Display="Dynamic" ControlToValidate="txtSellingPrice"
                    Type="Currency" Operator="DataTypeCheck"></asp:CompareValidator>
                <asp:RequiredFieldValidator ID="rfvSellingPrice" runat="server" ErrorMessage="* Campo obbligatorio"
                    ValidationGroup="vgInsertBook" CssClass="failureNotification" Display="Dynamic"
                    ControlToValidate="txtSellingPrice"></asp:RequiredFieldValidator>
                <br />
                <asp:Label ID="lblUniversity" runat="server" Text="Ateneo"></asp:Label><br />
                <asp:DropDownList ID="ddlUniversity" CssClass="StandardTextBox" runat="server" DataTextField="Name" AutoPostBack="True"
                    AppendDataBoundItems="true" DataValueField="IdUniversity" OnSelectedIndexChanged="ddlUniversity_SelectedIndexChanged">
                    <asp:ListItem Selected="True" Enabled="true" Value="0">-- Seleziona --</asp:ListItem>
                </asp:DropDownList>
                <br />
                <br />
                <asp:Label ID="lblFaculty" runat="server" Text="Facoltà"></asp:Label><br />
                <asp:DropDownList ID="ddlFaculty" CssClass="StandardTextBox" runat="server" DataTextField="Name" DataValueField="IdFaculty"
                    AppendDataBoundItems="true">
                    <asp:ListItem Selected="True" Enabled="true" Value="0">-- Seleziona --</asp:ListItem>
                </asp:DropDownList>
                <br />
                <br />
                <asp:Panel ID="pnlCoverUpload" runat="server" Visible="true">
                    <asp:Label ID="lblCoverImage" runat="server" Text="Inserisci la copertina del libro"></asp:Label><br />
                    <div style="font-size: 0.9em;">
                        <i>La copertina del libro faciliterà il riconoscimento del libro stesso da parte di
                            un possibile acquirente.</i><br />
                        <i>È possibile inserire al posto della copertina anche una foto del libro stesso in
                            modo tale che l'acquirente possa giudicare lo stato del libro.</i>
                    </div>
                    <asp:FileUpload ID="CoverImageFileUpload" runat="server" CssClass="StandardTextBox" />
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" CssClass="failureNotification"
                        ErrorMessage="Estensione file non supportata!(solo  .gif, .jpg, .jpeg, .png files sono supportati)"
                        ValidationExpression="^.+(.jpg|.JPG|.gif|.GIF|.jpeg|JPEG|.png|.PNG)$" ControlToValidate="CoverImageFileUpload"></asp:RegularExpressionValidator>
                    <br />
                    <div style="font-size: 0.9em; color: Red;">
                        Cliccare su anteprima per uplodare il file e vedere l'anteprima.
                    </div>
                    <asp:Button ID="btnFileupload" runat="server" Text="Anteprima" Width="100px" Height="25px" OnClick="btnFileupload_Click" />
                </asp:Panel>
                <asp:Panel ID="pnlPreview" runat="server" Visible="false">
                    <asp:Button ID="ResetUploadCover" runat="server" CssClass="StandardButton" Text="Cambia immagine" OnClick="ResetUploadCover_Click" />
                    <br />
                    <asp:Label ID="lblPreview" runat="server" Text="Anteprima della copertina del libro"></asp:Label><br />
                    <div style="margin: 2px;">
                        <asp:Image ID="PreviewBookImage" runat="server" ImageUrl="~/Images/no-image.gif"
                            Width="60%" />
                    </div>
                </asp:Panel>
            </div>
        </div>
        <table width="100%" style="margin-top:15px;">            
            <tr>
                <td colspan="2">
                    <div style="text-align: left">
                        <asp:Panel runat="server" ID="pnlInsertNewBook">
                            <asp:Button ID="btnInsertBook" runat="server"  CssClass="StandardButton" Text="Inserisci libro" OnClick="btnInsertBook_Click"
                                CausesValidation="true" ValidationGroup="vgInsertBook" />&nbsp;&nbsp;
                            <asp:Button ID="btnAnnulla" runat="server" CssClass="StandardButton" Text="Reset" OnClick="btnAnnulla_Click" />
                        </asp:Panel>
                        <asp:Panel runat="server" ID="pnlUpdateBook" Visible="false">
                            <asp:Button ID="btnUpdateBook" runat="server" CssClass="StandardButton" Text="Aggiorna" ValidationGroup="vgInsertBook"
                                CausesValidation="true" OnClick="btnUpdateBook_Click" />
                        </asp:Panel>
                    </div>
                </td>
            </tr>
        </table>
        <div>
            <asp:ValidationSummary ID="vsInsertBook" runat="server" DisplayMode="BulletList"
                CssClass="failureNotification" EnableClientScript="true" HeaderText="Attenzione:" />
        </div>
    </asp:Panel>
    <asp:Panel ID="pnlInsertBookSuccessfullyCompleted" runat="server" Visible="false">
        <table>
            <tr>
                <td>
                    <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/icon-success.png" />
                </td>
                <td style="vertical-align: middle; padding-left: 20px;">
                    <asp:Label ID="Label1" Text="Inserimento libro effettuato con successo!" runat="server"
                        CssClass="failureNotification"></asp:Label>
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlUpdateBookSuccessfullyCompleted" runat="server" Visible="false">
        <table>
            <tr>
                <td>
                    <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/icon-success.png" />
                </td>
                <td style="vertical-align: middle; padding-left: 20px;">
                    <asp:Label ID="Label2" Text="Aggiornamento libro effettuato con successo!" runat="server"
                        CssClass="failureNotification"></asp:Label>
                </td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>
